// 诊断历史详情页
const app = getApp();

Page({
  data: {
    record: null,
    showFullContent: false
  },
  
  onLoad(options) {
    // 从全局变量获取当前查看的记录详情
    const record = app.globalData.currentRecordDetail;
    
    if (record) {
      this.setData({
        record: record
      });
    } else {
      wx.showToast({
        title: '未找到记录详情',
        icon: 'none'
      });
      
      // 延迟返回上一页
      setTimeout(() => {
        wx.navigateBack();
      }, 1500);
    }
  },
  
  // 切换显示完整内容
  toggleFullContent() {
    this.setData({
      showFullContent: !this.data.showFullContent
    });
  },
  
  // 预览图片
  previewImage() {
    if (this.data.record && this.data.record.image_url) {
      wx.previewImage({
        urls: [this.data.record.image_url]
      });
    } else {
      wx.showToast({
        title: '无图片可预览',
        icon: 'none'
      });
    }
  },
  
  // 返回上一页
  goBack() {
    wx.navigateBack();
  }
});
